<template>
  <div class="container-y">
    <bodyWrap :isShow="bodyShow">
      <div slot="body" class="infoWrap" v-if="bodyShow">

        <!--反馈内容-->
        <div class="d-item-wrap">
          <div class="d-title">
            反馈内容
          </div>
          <div class="d-content">
            <div class="item"
                 v-for="item of dt">
              <div class="label">
                {{item.label}}
              </div>
              <div class="txt">
                <div class="txt-multiLine">
                  {{item.value}}
                </div>
              </div>
            </div>
          </div>
        </div>

        <transition-group name="fadeShow">
          <!--报告汇总-->
          <div class="d-item-wrap"
               :key="11">
            <div class="d-title"></div>
            <div class="d-content">
              <div class="item">
                <div class="label">
                  报告统计
                </div>
                <div class="txt">
                  <div class="txt-multiLine">
                    共下发 <span class="blue1Color"> {{count.allCount}} </span> 家，<span class="blue1Color"> {{count.feedbackCount}} </span>家反馈，<span
                    class="redColor"> {{count.unfeedbackCount}} </span> 家未反馈
                  </div>
                </div>
              </div>
            </div>
          </div>

          <!--已反馈-->
          <div class="d-item-wrap"
               :key="12"
               v-if="feedBackList.length">
            <div class="d-title">已反馈</div>
            <div class="d-content">
              <div class="item fold-hide"
                   v-for="item in feedBackList">
                <div class="feedBack-item">
                  <div class="fb-label">单位：</div>
                  {{item.deptName}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    联系人：
                  </div>
                  {{item.userName}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    联系方式：
                  </div>
                  {{item.mobile}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    反馈时间：
                  </div>
                  {{item.feedbackTime}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    是否超时：
                  </div>
                  {{item.inTimeCount == 0?'否':'是'}}
                </div>
                <div class="feedBack-item" v-for="dd of item.df">
                  <div class="fb-label">{{dd.label}}：</div>
                  {{dd.value}}
                </div>
              </div>
            </div>
            <foldWrap :list="feedBackList"></foldWrap>
          </div>

          <!--未反馈-->
          <div class="d-item-wrap"
               :key="13"
               v-if="unFeedBackList.length">
            <div class="d-title">未反馈</div>
            <div class="d-content">
              <div class="item fold-hide"
                   v-for="item in unFeedBackList">
                <div class="feedBack-item">
                  <div class="fb-label">单位：</div>
                  {{item.deptName}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    联系人：
                  </div>
                  {{item.userName}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    联系方式：
                  </div>
                  {{item.mobile}}
                </div>
                <div class="feedBack-item">
                  <div class="fb-label">
                    是否超时：
                  </div>
                  {{item.inTimeCount == 0?'否':'是'}}
                </div>
              </div>
            </div>
            <foldWrap :list="unFeedBackList"></foldWrap>
          </div>

        </transition-group>

      </div>
    </bodyWrap>
  </div>
</template>

<script>

  import foldWrap from "../commonComponents/fold.vue"

  export default {
    data() {
      return {
        bodyShow: true,
        dt: {},
        id: false,
        count: false,
        feedBackList: [],
        unFeedBackList: [],
      }
    },
    methods: {
      init() {

        this.id = _data.dailyDetail.reportId;

        this.dt = _data.dailyDetail.configList;

        this.getCount();

        this.getFeedBackList();
      },
      getCount() {
        let data = {
          id: this.id,
          deptId: _data.dailyDetail.checkedItem.deptId,
          userId: _data.userInfo.userId
        };
        let urlData = `${data.id}/${data.deptId}`;

        _ajax.noLoading(_ajaxUrls.dailyTaskFeedbackListCount.url + urlData, data,
          (ajData) => {

            this.count = ajData.data;

          }, _ajaxUrls.dailyTaskFeedbackListCount.type);
      },
      getFeedBackList() {
        // let userType = _showControl["317"]["317001"]?1:2;

        /*pageIndex: “1”   // 当前页码，大于等于1
          pageSize:“详情情报“   // 每页数据条数， 默认20
          state: 1  // 状态：默认值1；可选值：1已反馈；2：未反馈；
          taskId: 1  // 任务ID
          deptId: 1 // 部门ID
          userType： 1  // 1:发布者  2：非CII反馈者
          feedbackId: 1  // 反馈ID  默认-1 不为-1，可查询反馈内容详情
        */

        let data = {
          pageIndex: 1,
          pageSize: 1000,
          taskId: this.id,
          state: 1,
          userType: 1,
          deptId: _data.dailyDetail.checkedItem.deptId,
          userId: _data.userInfo.userId
        };

        _ajax.noLoading(_ajaxUrls.dailyTaskFeedbackListCount.url, data,
          (ajData) => {
            let list = ajData.data.list;

            list = list.map((i) => {
              i.df = this.goFeedBackDetail(i);
              return i;
            });

            this.feedBackList = list;

          }, _ajaxUrls.dailyTaskFeedbackListCount.type);

        data.state = 0;

        _ajax.noLoading(_ajaxUrls.dailyTaskFeedbackListCount.url, data,
          (ajData) => {

            this.unFeedBackList = ajData.data.list;

          }, _ajaxUrls.dailyTaskFeedbackListCount.type);

      },
      goFeedBackDetail(item) {

        let val = item.content;

        let valArr = val.split("$$");

        valArr.forEach((i) => {

          let vi = i.split("=");

          let key = vi[0];

          _data.dailyDetail.configList[key].value = vi[1];

        });

        return _data.dailyDetail.configList;
      },
    },
    created() {
      this.init()
    },
    components: {
      foldWrap,
    },
  }

</script>
